import sortedcontainers
class MyCalendarTwo(object):

    def __init__(self):
        self.d = sortedcontainers.SortedDict()

    def book(self, start, end):
        self.d[start] = self.d.setdefault(start, 0) + 1
        self.d[end] = self.d.setdefault(end, 0) - 1
        values = self.d.values()
        t = 0
        for value in values:
            t += value
            if t > 2:
                self.d[start] -= 1
                self.d[end] += 1
                return False
        return True

